<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>订单监控</title>
</head>
<body>
    <div class="pt-5  pl-20 pr-20 pb-20">
        <form id="itemEdit" name="itemEdit" method="post" action="../ashx/spui.ashx" class="form form-horizontal">
            <input type="hidden" class="actionValue" id="editAction" name="action" value="add" />
            <input type="hidden" id="id" name="id" />
            <input type="hidden" id="tablename" name="tablename" value="" />
            <input type="hidden" id="tablemidname" name="tablemidname" value="" />
            <input type="hidden" id="ftype" name="ftype" value="20170514" />
            <input type="hidden" id="hcrainbackid" name="hcrainbackid" value="1" />
            <input type="hidden" id="ffhcrwfadduser" name="ffhcrwfadduser" value="" />
            <div id="tab-category" class="HuiTab">
                <div class="tabBar cl" id="tab-categorybar">
                    <span>生产管理</span><span>备注</span><span>图片</span><span>流程日志</span>
                </div>
                <div class="tabCon" id="divtab1">
                    <div id="divshow1">
                        <div class="page-container">
                            <table class="table table-border table-bordered table-bg" id="tablezjList">
                                <thead>
                                    <tr>
                                        <th colspan="7" scope="col">组件信息</th>
                                    </tr>
                                    <tr class="text-c">
                                        <th>分类</th>
                                        <th>品名/图号</th>
                                        <th>规格/名称</th>
                                        <th>数量</th>
                                        <th>单位</th>
                                        <th>备注</th>
                                        <th>进度</th>
                                    </tr>
                                </thead>
                                <tbody id="tbody1">
                                </tbody>
                            </table>
                            <table class="table table-border table-bordered table-bg mt-20">
                                <thead>
                                    <tr>
                                        <th scope="col">工序</th>
                                        <th scope="col">是否品检</th>
                                        <th scope="col">说明</th>
                                        <th scope="col">已处理数量</th>
                                    </tr>
                                </thead>
                                <tbody id="gsInfo">
                                    <!--  <tr>
                                        <td>工序1</td>
                                        <td><span id="lbServerName">http://127.0.0.1/</span></td>
                                        <td>
                                            <input type="text" class="input-text" name="forderMNo" id="forderMNo" nullmsg="不能为空" datatype="*1-16" placeholder="不能为空" /></td>
                                    </tr>-->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="tabCon" id="divtab2">
                    <div id="divshow2">
                        <div class="row cl">
                            <label class="form-label col-2">图片摘要：</label>
                            <div class="formControls col-8">
                                <textarea name="fbj" id="fbj" cols="" rows="" class="textarea" placeholder="说点什么...最少输入10个字符" onkeyup="textarealength(this,200)"></textarea>
                                <p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tabCon" id="divtab3">
                    <div id="divshow3">
                        <input type="hidden" id="ffv10" name="ffv10" value="" />
                        <div class="row cl">
                            <div class="col-2">相片<img id="imgExist" src="" width="110px" height="150px"></div>
                            <div class="col-8">
                                <div id="uploadfileQueue" style="padding: 3px;"></div>
                                <div id="file_upload"></div>
                                <br />
                                <img alt="" src="../uploadifyjs/images/BeginUpload.gif" width="77" height="23" onclick="doUplaod()" />
                                <img alt="" src="../uploadifyjs/images/CancelUpload.gif" width="77" height="23" onclick="closeLoad()" />
                            </div>

                        </div>


                    </div>
                </div>
                <div class="tabCon" id="divtab4">
                    <div id="divshow4">
                        <div id="divforhcrainwflog">
                        </div>
                    </div>
                </div>

            </div>
            <div class="cl" style="display: none;" id="fold_category">
                <ul id="Huifold2" class="Huifold">
                    <li class="item">
                        <h4>基本设置<b>+</b></h4>
                        <div class="info" id="divfold1" style="display: block;">
                        </div>
                    </li>
                    <li class="item">
                        <h4>基本设置2<b>+</b></h4>
                        <div class="info" id="divfold2" style="display: block;">
                        </div>
                    </li>
                    <li class="item">
                        <h4>基本设置3<b>+</b></h4>
                        <div class="info" id="divfold3" style="display: block;"></div>
                    </li>
                    <li class="item">
                        <h4>审核日志<b>+</b></h4>
                        <div class="info" id="divfold4" style="display: block;"></div>
                    </li>
                </ul>
            </div>
            <div class="row cl">
                <div class="col-6 col-offset-4">
                    <button onclick="changeshowtype();" class="btn btn-danger radius" type="button">切换显示</button>
                    <button onclick="savegswork();" class="btn btn-danger radius" type="button">保存</button>
                    <!-- <button class="btn btn-primary radius" type="submit" id="btn_hcrwf_save" style="display: none;">保存</button>&nbsp;&nbsp;-->
                    <!--<button class="btn btn-secondary radius" type="button" id="btn_reset">重置</button>&nbsp;&nbsp;-->
                    <button onclick="layer_close();" class="btn btn-default radius" type="button">返回</button>&nbsp;&nbsp;
                </div>
            </div>
            <div class="row cl">
                <div class="col-10" id="divforhcrfbutton" style="text-align: center;">
                </div>
            </div>
        </form>
    </div>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="../lib/Validform/5.3.2/Validform.js"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_au_wf.js"></script>
    <script type="text/javascript" src="../js/hcrainwf.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>


    <!-- 文件上传方法SSSSSSSSSSSSSSS-->
    <link href="../uploadifyjs/uploadify.css" rel="stylesheet" type="text/css" />
    <script src="../uploadifyjs/swfobject.js" type="text/javascript"></script>
    <script src="../uploadifyjs/jquery.uploadify.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../newbasejs/uploadifyui.js"></script>
    <!-- 文件上传方法EEEEEEEEEEEEEEE-->
    <script type="text/javascript">
        var divshowtype = 1;
        var Mhcimgid = "#ffv10";
        urlpcend = "hcrw.html";
        var gygsRight = [];//工艺权限
        //加载处理
        function loadin() {

            //本页面 
            spsetBase("order_sp", "id", "order_sp as T", "*", "#tablelist", "hsflow", "订单监控", "hhwork");
            //$("#imgExist").attr("src", "../ashx/GetPhotoHandler.ashx?mid=" + PhotoId);

            $.Huitab("#tab-category .tabBar span", "#tab-category .tabCon", "current", "click", "0");

            $.Huifold("#Huifold2 .item h4", "#Huifold2 .item .info", "", 3, "click");
            /*5个参数顺序不可打乱，分别是：相应区,隐藏显示的内容,速度,类型,事件 mouseover click */

            Mhcloadback[0] = "fv10";
            //工艺权限    //工序列表 表定义 type:20170505 fv1名称 fv2说明  nv1序号 fv3负责的角色ID，fv4负责的角色Name
            hcdosel("id,fv1,fv3,fv4,nv1", "table_sp", "type=20170505", "", "", "", function (data) {
                gygsRight = JSON.parse(data);
            });

        }
        function loadback(data) {
            //console.log(HCUser.HCUtitle);
            // loadDepInfo(data["fv9"], data["fv10"]);
            //loadUserInfo(data["fv10"], data["nv2"]);
            $("#imgExist").attr("src", "../ashx/GetPhotoHandler.ashx?mid=" + data["fv10"]);
            hcrfbutton();
            //数据加载
            hcdosel("t.id,t.fv1,t.fv2,t.fv3,t.fv4,t.fv5,t.fv6,t.nv1,tgj.fv4 as gsname,tgj.nv3 as gshasok", "table_sp  as t left join table_sp as tgj on  t.id=tgj.maintype and tgj.type=20170520", "t.maintype=" + Hcaumid, "", "", "t.fv4,t.id,tgj.nv1",
                function (data) {
                    var obj = JSON.parse(data);
                    var trStr = '';//动态拼接table //
                    var html = '';
                    var 工序信息 = "";
                    var oldid = "";
                    for (var i = 0; i < obj.length; i++) {
                        if (obj[i].id != oldid) {
                            oldid = obj[i].id;
                            if (工序信息 != "") {
                                trStr = trStr.replace('#hcgsinfo#', 工序信息);
                            }
                            工序信息 = "";
                            //循环遍历出json对象中的每一个数据并显示在对应的td中 
                            trStr += '<tr class="text-c" onclick="loadgsinfos(' + obj[i].id + ',this)">';//拼接处规范的表格形式 

                            trStr += '<td >' + obj[i].fv4 + '</td>';
                            trStr += '<td>' + obj[i].fv1 + '</td>';
                            trStr += '<td >' + obj[i].fv2 + '</td>';
                            trStr += '<td>' + obj[i].nv1 + '</td>';
                            trStr += '<td>' + obj[i].fv5 + '</td>';
                            trStr += '<td>' + obj[i].fv6 + '</td>';
                            trStr += '<td>#hcgsinfo#</td>';
                            console.log(obj[i].gshasok);
                            console.log(obj[i].nv1);
                            if (Number(obj[i].gshasok) >= Number(obj[i].nv1))
                            { 工序信息 += '<span class ="label label-success">' + obj[i].gsname + '</span>'; }
                            else
                            { 工序信息 += '<span class ="label label-danger">' + obj[i].gsname + '</span>'; }

                            //trStr += "<td><a href='#'style='text-decoration:none' onclick='Delete(\"" + obj[i].NVFID + "\")'>删除</a><td>";
                            trStr += '</tr>';
                        }
                        else {
                            if (Number(obj[i].gshasok) >= Number(obj[i].nv1))
                            { 工序信息 += '<span class ="label label-success">' + obj[i].gsname + '</span>'; }
                            else
                            { 工序信息 += '<span class ="label label-danger">' + obj[i].gsname + '</span>'; }
                        }
                    }
                    if (工序信息 != "") {
                        trStr = trStr.replace('#hcgsinfo#', 工序信息);
                    }
                    $("#tbody1").html(trStr);//运用html方法将拼接的table添加到tbody中return;


                });

        }
        //加载工艺工序
        function loadgsinfos(id, obj) {

            var trs = document.getElementById('tablezjList').getElementsByTagName('tr');
            for (var o = 0; o < trs.length; o++) {
                if (trs[o] == obj) {
                    trs[o].style.backgroundColor = '#DFEBF2';
                }
                else {
                    trs[o].style.backgroundColor = '';
                }
            }

            //数据加载
            hcdosel("id,fv1,fv2,fv3,fv4,fv5,fv6,nv1,nv3", "table_sp", "type=20170520 and maintype=" + id, "", "", "nv1",
                function (data) {
                    var obj = JSON.parse(data);
                    var trStr = '';
                    var html = '';
                    for (var i = 0; i < obj.length; i++) {
                        trStr += '<tr class="text-c">';
                        trStr += '<td >' + obj[i].nv1 + "-" + obj[i].fv4 + "-" + obj[i].fv1 + '</td>';
                        trStr += '<td >' + obj[i].fv3 + '</td>';
                        trStr += '<td >' + obj[i].fv2 + '</td>';
                        if (gscanwork(obj[i].fv1)) {
                            trStr += '<td >' + '<input type="text" class="input-text" name="gsslnv3" id="' + obj[i].id + 'gsslnv3" datatype="*0-16" placeholder="已处理数量" value="' + obj[i].nv3 + '"  />' + '</td>';
                        }
                        else {
                            trStr += '<td >' + obj[i].nv3 + '</td>';
                        }

                        trStr += '</tr>';
                    }
                    $("#gsInfo").html(trStr);
                });
        }
        function gscanwork(id)//根据工序ID 查看当前人员是否可以操作
        {
            var info = gygsRightGet(id);
            var reInfo = info.fv4;
            reInfo = reInfo.replaceAll(" ", ",");
            if (info != null && reInfo != "" && checkhcwfacess(HCUser.HCUtitle, reInfo)) {
                return true;
            }
            else {
                return false;
            }
        }
        function gygsRightGet(id)//根据ID 找到工序信息
        {
            for (var i = 0, l = gygsRight.length; i < l; i++) {
                if (gygsRight[i].id == id) {
                    return gygsRight[i];

                }
            }
        }
        //保存工序进度
        function savegswork() {
            //HCUser.HCUtitle;
            //if (checkhcwfacess(HCUser.HCUtitle, datainfo.hcrdotitle)) 
            //$("div[id]") 选择所有含有id属性的div元素 
            //$("input[name='keleyicom']") 选择所有的name属性等于'keleyicom'的input元素 
            //$("input[name!='keleyicom']") 选择所有的name属性不等于'keleyicom'的input元素 
            //$("input[name^='keleyi']") 选择所有的name属性以'keleyi'开头的input元素 
            //$("input[name$='keleyi']") 选择所有的name属性以'keleyi'结尾的input元素 
            //$("input[name*='keleyi']") 选择所有的name属性包含'keleyi'的input元素 
            var listggslnv = $("input[name='gsslnv3']");

            for (var i = 0; i < listggslnv.length; i++) {
                console.log(listggslnv[i].id.replace('gsslnv3', ''));
                console.log(listggslnv[i].value);
                var addinfo = "nv3%" + listggslnv[i].value;
                hcdoedit("table_sp", "id", listggslnv[i].id.replace('gsslnv3', ''), addinfo, function (info) {

                    if (i == listggslnv.length && (info == "ok" || info == "更新成功"))
                        layer.msg("保存成功", { icon: 1 });


                });

            }

        }
        //切换事件
        function changeshowtype() {
            if (divshowtype == 1) {
                $("#divshow1").appendTo("#divfold1");
                $("#divshow2").appendTo("#divfold2");
                $("#divshow3").appendTo("#divfold3");
                $("#divshow4").appendTo("#divfold4");
                $("#fold_category").show();
                $("#tab-category").hide();

                divshowtype = 2;
            }
            else {
                $("#divshow1").appendTo("#divtab1");
                $("#divshow2").appendTo("#divtab2");
                $("#divshow3").appendTo("#divtab3");
                $("#divshow4").appendTo("#divtab4");
                $("#fold_category").hide();
                $("#tab-category").show();
                divshowtype = 1;
            }

        }
    </script>

</body>
</html>
